package com.wondertek.onvif.service.auth;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.net.HttpURLConnection;

/**
 * 无认证策略实现
 */
@Slf4j
@Component
public class NoAuthStrategy implements AuthenticationStrategy {
    
    private static final Logger log = LoggerFactory.getLogger(NoAuthStrategy.class);
    
    @Override
    public String buildAuthHeader(String username, String password, String serviceUrl, String method) {
        // 无认证不需要认证头
        log.debug("使用无认证方式");
        return null;
    }
    
    @Override
    public boolean isSupported(HttpURLConnection connection) {
        // 无认证总是支持的，作为最后的备选方案
        return true;
    }
    
    @Override
    public String getAuthType() {
        return "None";
    }
    
    @Override
    public int getPriority() {
        return 999; // 最低优先级，作为最后的备选方案
    }
}